import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './user/user.module';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
    //token
    JwtModule.registerAsync({
      global:true,
      imports:[ConfigModule],
      inject:[ConfigService],
      useFactory:()=>({
        secret:'hopu',
        signOptions: {
          expiresIn:'60s',
        },
      }),
    }),
    TypeOrmModule.forRoot({
      type:'mysql', //数据库类型
      host:'localhost', //主机名
      port:3306,  //端口号
      username:'root',  //用户名
      password:'root',  //密码
      database:'manageadmin', //数据库名
      //下面两个配置项的作用就是让数据库中的表与代码中的实体配置双向同步
      autoLoadEntities:true,  //自动加载实体配置
      synchronize:true,   //是否将实体同步到数据库
    }),
    UserModule,
    
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
